<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 设置本地存储 key,value
        // localStorage.setItem('name','laowang');

        // 获取本地存储 key
        // console.log(localStorage.getItem('name'));

        // 删除本地存储 key
        // localStorage.removeItem('name');

        // console.log(localStorage.getItem('name'));


        let user = {
            username :'cris',
            age:18
        }


        // 会话存储
        // 设置
        sessionStorage.setItem('user',JSON.stringify(user));

        // // 获取
        console.log(JSON.parse(sessionStorage.getItem('user')).age);

        // // 删除
        // sessionStorage.removeItem('lastName');

        // // 获取
        // console.log(sessionStorage.getItem('lastName'));


    </script>
</body>
</html>